#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m;
int head[N], w[N];
int ver[N << 1], Next[N << 1], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
struct Node {
  int cnt;
  int ch[2];
} tr[N * 120];
#define cnt(p) tr[p].cnt
#define lc(p) tr[p].ch[0]
#define rc(p) tr[p].ch[1]
int newnode(int p) {
  static int tot = 0;
  ++tot;
  cnt(tot) = cnt(p);
  lc(tot) = lc(p);
  rc(tot) = rc(p);
  return tot;
}
void insert(int& rt, int x) {
  rt = newnode(rt);
  int p = rt;
  cnt(p)++;
  per(i, 29, 0) {
    int c = (x & (1 << i)) ? 1 : 0;
    tr[p].ch[c] = newnode(tr[p].ch[c]);
    p = tr[p].ch[c];
    cnt(p)++;
  }
}
int query(int p1, int p2, int x) {
  int res = 0;
  per(i, 29, 0) {
    int c = (x & (1 << i)) ? 1 : 0;
    if (cnt(tr[p2].ch[c]) <= cnt(tr[p1].ch[c])) c ^= 1;
    p1 = tr[p1].ch[c], p2 = tr[p2].ch[c];
    if (c) res |= 1 << i;
  }
  return res;
}
int dep[N], st[N][18];
int s[N], t[N], o[N];
void dfs(int u, int fu) {
  s[u] = t[u] = t[fu];
  insert(t[u], w[u]);
  o[u] = o[fu];
  insert(o[u], w[u]);
  dep[u] = dep[fu] + 1;
  st[u][0] = fu;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u);
    t[u] = t[v];
  }
}
void init_st() {
  rep(j, 1, 16) rep(i, 1, n) st[i][j] = st[st[i][j - 1]][j - 1];
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  per(i, 16, 0) if (d & (1 << i)) u = st[u][i];
  if (u == v) return u;
  per(i, 16, 0) if (st[u][i] != st[v][i]) u = st[u][i], v = st[v][i];
  return st[u][0];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> w[i];
  rep(i, 2, n) {
    int u, v;
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  dfs(1, 0);
  init_st();
  while (m--) {
    int op, x, y, z;
    cin >> op >> x >> y;
    if (op == 1) {
      z = query(s[x], t[x], ~y);
      cout << (y ^ z) << endl;
    } else {
      cin >> z;
      int f = lca(x, y);
      int ff = st[f][0];
      int z1 = query(o[ff], o[x], ~z);
      int z2 = query(o[ff], o[y], ~z);
      cout << max(z1 ^ z, z2 ^ z) << endl;
    }
  }
  return 0;
}